package com.yunxi.controller.order;

import com.yunxi.core.web.ApiResult;
import com.yunxi.core.web.CurrentUser;
import com.yunxi.core.web.LoginInfo;
import com.yunxi.core.web.ResponseUtil;
import com.yunxi.order.service.OrderCustomerDubboService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * </p>
 * @author
 * @since 2019-09-06
 */
@RestController
@RequestMapping("/admin/orderExperience")
@Api(tags = "pms:orderExperience", description = "接口")
public class OrderExperienceController {
 private static final Logger logger = LoggerFactory.getLogger(OrderExperienceController.class);

    @Autowired
    OrderCustomerDubboService orderCustomerDubboService;

    /** 绑定exp */
    @PostMapping("/hire")
    @ApiOperation(value = "绑定渠道商体验车")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query", name = "orderCustomerNo", value = "lingshoudanhao", required = true, dataType = "string"),
            @ApiImplicitParam(paramType="query", name = "vin", value = "vin", required = true, dataType = "string")
    })
    public ApiResult hire(String orderCustomerNo,String vin, @CurrentUser LoginInfo loginInfo) throws Exception {
        orderCustomerDubboService.hire(orderCustomerNo,vin);
        return ResponseUtil.ok();
    }

    /** 解绑订货单 */
    @PostMapping("/revert")
    @ApiOperation(value = "解绑渠道商体验车")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query", name = "vin", value = "vin", required = true, dataType = "string")
    })
    public ApiResult revert(String vin, @CurrentUser LoginInfo loginInfo) throws Exception {
        orderCustomerDubboService.revert(vin);
        return ResponseUtil.ok();
    }

    /** 解绑订货单 */
    @PostMapping("/cancel")
    @ApiOperation(value = "撤销体验车")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query", name = "vin", value = "vin", required = true, dataType = "string")
    })
    public ApiResult cancel(String vin, @CurrentUser LoginInfo loginInfo) throws Exception {
        orderCustomerDubboService.cancel(vin);
        return ResponseUtil.ok();
    }
}
